package once

import "sync"

type SlowComplicatedParser interface {
	Parse(string) string
}

var parser SlowComplicatedParser
var once sync.Once

func Parse(dataToParse string) string {

	once.Do(func() {
		parser = initParser()
	})

	return parser.Parse(dataToParse)

}

func initParser() SlowComplicatedParser {
	//do some Thing
	return &implement1{}
}

type implement1 struct {
}

func (implement12 implement1) Parse(string) string {
	return "done"
}
